home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / public / SciAn / src / ScianIDsParser.c < prev    next >
C/C++ Source or Header  |  1994-08-01  |  2KB  |  57 lines

  1. /* ScianIDsParser.c: John R. Murray. Writes ScianIDsDefiner.c based on the
  2.  * contents of ScianIDs.h. Really!
  3.  */
  4.  
  5. #include "Scian.h"
  6. #include "ScianTypes.h"
  7. #include "ScianNames.h"
  8.  
  9. #define TMPBUFSIZ 1024
  10. #define INFILE "ScianIDs.h"
  11. #define OUTFILE "ScianIDsDefiner.c"
  12.  
  13. main()
  14. {
  15.     FILE *inFile;
  16.     FILE *outFile;
  17.     char tmpBuf[TMPBUFSIZ];
  18.     char tmpStr[TMPBUFSIZ];
  19.     NameTyp tmpNum;
  20.  
  21.     if (!(inFile = fopen(INFILE, "r")))
  22.     {
  23.     fprintf(stderr, "ScianIDsParser: Couldn't open %s\n", INFILE);
  24.     exit(-1);
  25.     }
  26.  
  27.     if (!(outFile = fopen(OUTFILE, "w")))
  28.     {
  29.     fprintf(stderr, "ScianIDsParser: Couldn't open %s\n", OUTFILE);
  30.     exit(-1);
  31.     }
  32.  
  33.     fprintf(outFile, "/* %s: John R. Murray\n", OUTFILE);
  34.     fprintf(outFile, " * WARNING! This file is automatically generated by ScianIDsParser.c. Any\n");
  35.     fprintf(outFile, " * changes that you make to this file will be squashed like a tiny little\n");
  36.     fprintf(outFile, " * bug the next time someone (for example, 'make') runs ScianIDsParser\n");
  37.     fprintf(outFile, " */\n\n");
  38.     fprintf(outFile, "#include \"Scian.h\"\n");
  39.     fprintf(outFile, "#include \"ScianTypes.h\"\n");
  40.     fprintf(outFile, "#include \"ScianNames.h\"\n");
  41.     fprintf(outFile, "#include \"ScianIDsDefiner.h\"\n\n");
  42.     fprintf(outFile, "void ParseScianIDs()\n");
  43.     fprintf(outFile, "{\n");
  44.  
  45.     while (fgets(tmpBuf, TMPBUFSIZ, inFile))
  46.     {
  47.     if (2 == sscanf(tmpBuf, "#define%s%ld", tmpStr, &tmpNum))
  48.     {
  49.         fprintf(outFile, "    DefineID(\"%s\", %ld);\n", tmpStr, tmpNum);
  50.     }
  51.     }
  52.  
  53.     fprintf(outFile, "}\n");
  54.     fclose(outFile);
  55. }
  56.  
  57.